package kz.pvnhome.pimrestore.android;

import java.io.File;

import android.os.Environment;

/**
 * Created: May 11, 2012 9:12:35 AM
 * @author victor
 */
public class Utils {
   private static boolean externalStorageAvailable = false;
   private static boolean externalStorageWriteable = false;

   private static void checkState() {
      String state = Environment.getExternalStorageState();

      if (Environment.MEDIA_MOUNTED.equals(state)) {
         externalStorageAvailable = externalStorageWriteable = true;
      } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
         externalStorageAvailable = true;
         externalStorageWriteable = false;
      } else {
         externalStorageAvailable = externalStorageWriteable = false;
      }
   }

   public static boolean isExternalStorageAvailable() {
      checkState();
      return externalStorageAvailable;
   }

   public static boolean isExternalStorageWriteable() {
      checkState();
      return externalStorageWriteable;
   }

   public static String getExternalStorageDirectory() {
      return Environment.getExternalStorageDirectory().getPath();
   }
}
